home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_07_01
/
v7n1080a.txt
< prev
next >
Wrap
Text File
|
1987-04-26
|
20KB
|
794 lines
/* JustSayYes.c
An example of Intuition use. Presenting: a generic color control window,
a very simple menu, and lots of odds and ends. 4/25/88 JMFiore dissidents.
This program is in the public domain. Use it as you see fit (with the
exception of distribution for a profit).
compiled and linked with Manx Aztec C v3.6 under AmigaDOS 1.2
cc +L JustSayYes.c
ln +cdb JustSayYes.o -lc32
*/
#include "functions.h"
#include "intuition/intuition.h"
/*---------------------------------defines---------------------------------*/
/* MyText(*RastPort, Xposition, Yposition, char *buffer) */
#define MyText(r,x,y,b) Move((r),(x),(y)); Text((r),(b),strlen(b))
#define INTUITION_REV 33L
#define GRAPHICS_REV 33L
#define DEPTH 3
#define MAX_COLORS 8 /* 2 raised to the DEPTH power */
/* #define COLLECT_RODENT_GYRATIONS */
/* uncomment the line above if you would like a less processor intensive
color slider update, vs. responding to every single mouse move. */
/* color requester gagdets.
These defines are used as ID numbers in order to keep track of which
color gadget is selected. CG0 - CG7 are the color select boxes, CGR, CGG
CGB are the RGB sliders, and CGSAVE, CGCANCEL are the Save/Cancel buttons. */
#define CGLOWEST 1
#define CG0 2
#define CG1 3
#define CG2 4
#define CG3 5
#define CG4 6
#define CG5 7
#define CG6 8
#define CG7 9
#define CGR 10
#define CGG 11
#define CGB 12
#define CGSAVE 13
#define CGCANCEL 14
#define CGHIGHEST 15
struct IntuitionBase *IntuitionBase=0L;
struct GfxBase *GfxBase=0L;
struct Window *back_wind=0L;
struct Window *color_wind=0L;
struct Screen *main_scrn=0L;
struct ViewPort *color_w_v_port=0L;
/* use the 80 character topaz font for the screen lettering */
struct TextAttr my_font_attr={(UBYTE *)"topaz.font",TOPAZ_EIGHTY,\
FS_NORMAL, FPF_ROMFONT};
struct NewScreen ns={0,0,640,200, DEPTH, 0,1, HIRES,\
SCREENBEHIND | CUSTOMSCREEN, &my_font_attr, \
(UBYTE *)"|| Color Window Example || ", NULL, NULL };
struct NewWindow b_nw={0,0,640,200, -1,-1, GADGETUP | GADGETDOWN | \
MENUPICK , SMART_REFRESH | ACTIVATE | BACKDROP | \
BORDERLESS, NULL, NULL, \
(UBYTE *)" Backdrop Window ",\
NULL, NULL, 640, 200, 640, 200, CUSTOMSCREEN};
USHORT sys_color_table[MAX_COLORS]={0xcbb,0x530,0xf00,0xf40,0xbf0,\
0x84f,0xbfd,0x48b};
/* Quit requester Auto() */
struct IntuiText qr_txt[]={\
{0,1,JAM1,20,10,NULL,(UBYTE *)"Quit for sure?"},\
{0,1,JAM1,5,3,NULL,(UBYTE *)"Okay"},\
{0,1,JAM1,5,3,NULL,(UBYTE *)"Naaahh"},};
/* Menu set-up */
struct IntuiText itxt[]={\
{0,1,JAM1,0,0,NULL,(UBYTE *)"-Quit-"},\
{0,1,JAM1,0,0,NULL,(UBYTE *)" Color"},};
struct MenuItem mi[]={\
{NULL,0,(0*10+1),(104+COMMSEQ),8,\
(ITEMTEXT | COMMSEQ | ITEMENABLED | HIGHBOX),\
NULL,(APTR)&itxt[0],NULL,'Q'},\
/* Color */
{NULL,0,(0*10+1),(52),8,\
(ITEMTEXT | ITEMENABLED | HIGHBOX),\
NULL,(APTR)&itxt[1],NULL},};
struct Menu main_menu[]={\
{&main_menu[1],0,0,72,0,MENUENABLED,\
"Project ",&mi[0]},\
{NULL,280,0,56,0,MENUENABLED,\
"Color ",&mi[1]},};
/* shapes for push buttons */
SHORT button50_pts[]={0,0, 50,0, 50,12, 0,12, 0,0};
SHORT button80_pts[]={0,0, 80,0, 80,12, 0,12, 0,0};
struct Border button50= {0,0,2,0,JAM1,5,&button50_pts[0],NULL};
struct Border button80= {0,0,3,0,JAM1,5,&button80_pts[0],NULL};
/* data chunk for color window, hi/un light, etc */
#define CGHSIZE 20 /* size of gadgets */
#define CGVSIZE 7
#define CGHOFF 30 /* offsets for successive gadgets */
#define CGVOFF 10
#define CGHPOS 170 /* initial position for starting gadget, CG0 */
#define CGVPOS 20
SHORT color_hi_pts[]={-4,-2, CGHSIZE+2,-2, CGHSIZE+2,CGVSIZE+1,
-4,CGVSIZE+1, -4,-2};
struct Border color_hi_light=\
{0,0,1,0,JAM1,5,&color_hi_pts[0],NULL};
struct Border color_un_light=\
{0,0,0,0,JAM1,5,&color_hi_pts[0],NULL};
struct IntuiText color_txt[]={\
{4,0,JAM1,15,3,NULL,(UBYTE *)"Cancel"},\
{5,0,JAM1,10,3,NULL,(UBYTE *)"Save"},\
{1,0,JAM1,-30,1,NULL,(UBYTE *)"R"},\
{1,0,JAM1,-30,1,NULL,(UBYTE *)"G"},\
{1,0,JAM1,-30,1,NULL,(UBYTE *)"B"},};
struct Image color_box[]={\
{0,0,CGHSIZE,CGVSIZE,0,NULL,0,0,NULL},\
{0,0,CGHSIZE,CGVSIZE,0,NULL,0,1,NULL},\
{0,0,CGHSIZE,CGVSIZE,0,NULL,0,2,NULL},\
{0,0,CGHSIZE,CGVSIZE,0,NULL,0,3,NULL},\
{0,0,CGHSIZE,CGVSIZE,0,NULL,0,4,NULL},\
{0,0,CGHSIZE,CGVSIZE,0,NULL,0,5,NULL},\
{0,0,CGHSIZE,CGVSIZE,0,NULL,0,6,NULL},\
{0,0,CGHSIZE,CGVSIZE,0,NULL,0,7,NULL},};
struct Image color_img[3];
struct PropInfo color_prop[]={\
{AUTOKNOB | FREEHORIZ, 0x0, 0, 0xffff/16+1, 0},\
{AUTOKNOB | FREEHORIZ, 0x0, 0, 0xffff/16+1, 0},\
{AUTOKNOB | FREEHORIZ, 0x0, 0, 0xffff/16+1, 0},};
struct Gadget color_gadg[]={\
{&color_gadg[1],25,72,50,12,GADGHCOMP, RELVERIFY,\
BOOLGADGET, (APTR)&button50,NULL,\
&color_txt[1],NULL,NULL,CGSAVE,NULL},\
{&color_gadg[2],40,20,110,9,GADGHCOMP,GADGIMMEDIATE |\
RELVERIFY | FOLLOWMOUSE,\
PROPGADGET ,(APTR)&color_img[0],NULL,\
&color_txt[2],NULL,(APTR)&color_prop[0],CGR,NULL},\
{&color_gadg[3],40,32,110,9,GADGHCOMP,GADGIMMEDIATE |\
RELVERIFY | FOLLOWMOUSE,\
PROPGADGET ,(APTR)&color_img[1],NULL,\
&color_txt[3],NULL,(APTR)&color_prop[1],CGG,NULL},\
{&color_gadg[4],40,44,110,9,GADGHCOMP,GADGIMMEDIATE |\
RELVERIFY | FOLLOWMOUSE,\
PROPGADGET ,(APTR)&color_img[2],NULL,\
&color_txt[4],NULL,(APTR)&color_prop[2],CGB,NULL},\
{&color_gadg[5], CGHPOS, CGVPOS, CGHSIZE, CGVSIZE,\
GADGHNONE | GADGIMAGE, GADGIMMEDIATE,\
BOOLGADGET ,(APTR)&color_box[0],NULL,\
NULL,NULL,NULL,CG0,NULL},\
{&color_gadg[6], CGHPOS, CGVPOS+CGVOFF, CGHSIZE, CGVSIZE,\
GADGHNONE | GADGIMAGE, GADGIMMEDIATE,\
BOOLGADGET ,(APTR)&color_box[1],NULL,\
NULL,NULL,NULL,CG1,NULL},\
{&color_gadg[7], CGHPOS, CGVPOS+2*CGVOFF, CGHSIZE, CGVSIZE, \
GADGHNONE | GADGIMAGE, GADGIMMEDIATE,\
BOOLGADGET ,(APTR)&color_box[2],NULL,\
NULL,NULL,NULL,CG2,NULL},\
{&color_gadg[8], CGHPOS, CGVPOS+3*CGVOFF, CGHSIZE, CGVSIZE, \
GADGHNONE | GADGIMAGE, GADGIMMEDIATE,\
BOOLGADGET ,(APTR)&color_box[3],NULL,\
NULL,NULL,NULL,CG3,NULL},\
{&color_gadg[9], CGHPOS+CGHOFF, CGVPOS, CGHSIZE, CGVSIZE, \
GADGHNONE | GADGIMAGE, GADGIMMEDIATE,\
BOOLGADGET ,(APTR)&color_box[4],NULL,\
NULL,NULL,NULL,CG4,NULL},\
{&color_gadg[10], CGHPOS+CGHOFF, CGVPOS+CGVOFF, CGHSIZE, CGVSIZE, \
GADGHNONE | GADGIMAGE, GADGIMMEDIATE,\
BOOLGADGET ,(APTR)&color_box[5],NULL,\
NULL,NULL,NULL,CG5,NULL},\
{&color_gadg[11], CGHPOS+CGHOFF, CGVPOS+2*CGVOFF, CGHSIZE, CGVSIZE, \
GADGHNONE | GADGIMAGE, GADGIMMEDIATE,\
BOOLGADGET ,(APTR)&color_box[6],NULL,\
NULL,NULL,NULL,CG6,NULL},\
{&color_gadg[12], CGHPOS+CGHOFF, CGVPOS+3*CGVOFF, CGHSIZE, CGVSIZE, \
GADGHNONE | GADGIMAGE, GADGIMMEDIATE,\
BOOLGADGET ,(APTR)&color_box[7],NULL,\
NULL,NULL,NULL,CG7,NULL},\
{NULL,170,72,80,12,GADGHCOMP, RELVERIFY,\
BOOLGADGET ,(APTR)&button80,NULL,\
&color_txt[0],NULL,NULL,CGCANCEL,NULL},};
struct NewWindow c_nw={100,20,270,100, -1,-1, GADGETDOWN | GADGETUP | \
MOUSEMOVE, SMART_REFRESH | ACTIVATE | WINDOWDRAG |\
WINDOWDEPTH | REPORTMOUSE, &color_gadg[0], NULL, \
(UBYTE *) " -Color Control- ", NULL, NULL,\
0,0,0,0, CUSTOMSCREEN};
/* color_box_ptr will indicate which pen color (image) needs to be
highlighted. Initialized to color 3 (pen #2) */
struct Gadget *color_box_ptr = &color_gadg[6];
VOID open_all(), damp_mop(), handle_main_messages(), handle_color_messages(),\
handle_main_menu(), setup_color(), handle_color_gadg(), hi_color(), \
update_color_pots();
/*------------------------------start of main()----------------------------*/
main()
{
LONG main_wait_bit, color_wait_bit, wait_mask;
/*-------------------------open Intuition and graph